package stream.part5;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class Demo01 {
    public static void main(String[] args) {
        List<String> randomString= Arrays.asList("AA","AAA","A","AAAA","AAAAAA","AAAAAAAAAAAAAAAAAA");
        String maxByIntermediateMax = randomString.stream().max(String :: compareTo).get();
        String minByIntermediateMin = randomString.stream().min(String :: compareTo).get();
        System.out.println("Intermediate Min() :- "+minByIntermediateMin+" Intermeidate Max() :- "+ maxByIntermediateMax);

        String minByCollectorsMinBy = randomString.stream().min(Comparator.naturalOrder()).get();
        String maxByCollectorsMaxBy = randomString.stream().max(Comparator.naturalOrder()).get();
        System.out.println("Collectors MinBy :- "+minByCollectorsMinBy+ " , Collectors maxBy is :- "+maxByCollectorsMaxBy);
    }
}
